package File;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Demo17 {
    public static void main(String[] args) throws FileNotFoundException {
        File file = new File("test1.txt");
        try(OutputStream outputStream = new FileOutputStream(file)) {
            String str = "你好";
            byte[] data = str.getBytes(StandardCharsets.UTF_8);
            outputStream.write(data);
            outputStream.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
